From: Bastien Nocera Date: Thu, 14 Jun 2012 11:57:09 +0000 (+0100) Subject: Always enable a11y X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~6472 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=de1eafb564b5cbd286188d0e6efe4b7c8ff9d927;p=gnome-shell.git Always enable a11y https://bugzilla.gnome.org/show_bug.cgi?id=678095 --- diff --git a/configure.ac b/configure.ac index 29354da29..eaf7daa86 100644 --- a/configure.ac +++ b/configure.ac @@ -81,6 +81,7 @@ GNOME_DESKTOP_REQUIRED_VERSION=3.5.1 PKG_CHECK_MODULES(GNOME_SHELL, gio-unix-2.0 >= $GIO_MIN_VERSION libxml-2.0 gtk+-3.0 >= $GTK_MIN_VERSION + atk-bridge-2.0 folks >= $FOLKS_MIN_VERSION libmutter >= $MUTTER_MIN_VERSION gjs-internals-1.0 >= $GJS_MIN_VERSION diff --git a/src/Makefile.am b/src/Makefile.am index 802379405..05c8457a8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -153,8 +153,6 @@ libgnome_shell_la_SOURCES = \ shell-wm-private.h \ gnome-shell-plugin.c \ shell-app.c \ - shell-a11y.h \ - shell-a11y.c \ shell-app-system.c \ shell-app-usage.c \ shell-contact-system.c \ diff --git a/src/main.c b/src/main.c index e398fd145..ad4fb3ac5 100644 --- a/src/main.c +++ b/src/main.c @@ -18,10 +18,10 @@ #include #include #include +#include #include #include -#include "shell-a11y.h" #include "shell-global.h" #include "shell-global-private.h" #include "shell-js.h" @@ -235,6 +235,20 @@ shell_perf_log_init (void) NULL, NULL); } +static void +shell_a11y_init (void) +{ + if (clutter_get_accessibility_enabled () == FALSE) + { + g_warning ("Accessibility: clutter has no accessibility enabled" + " skipping the atk-bridge load"); + } + else + { + atk_bridge_adaptor_init (NULL, NULL); + } +} + static void default_log_handler (const char *log_domain, GLogLevelFlags log_level, diff --git a/src/shell-a11y.c b/src/shell-a11y.c deleted file mode 100644 index 98ddcb958..000000000 --- a/src/shell-a11y.c +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ -/* - * Copyright (C) 2010 Igalia, S.L. - * - * Author: Alejandro Piñeiro Iglesias - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#include -#include -#include - -#include "shell-a11y.h" - -#define INIT_METHOD "gnome_accessibility_module_init" -#define DESKTOP_SCHEMA "org.gnome.desktop.interface" -#define ACCESSIBILITY_ENABLED_KEY "toolkit-accessibility" -#define AT_SPI_SCHEMA "org.a11y.atspi" -#define ATK_BRIDGE_LOCATION_KEY "atk-bridge-location" - -static gboolean -should_enable_a11y (void) -{ - GSettings *desktop_settings = NULL; - gboolean value = FALSE; - - desktop_settings = g_settings_new (DESKTOP_SCHEMA); - value = g_settings_get_boolean (desktop_settings, ACCESSIBILITY_ENABLED_KEY); - - g_object_unref (desktop_settings); - - return value; -} - -static char* -get_atk_bridge_path (void) -{ - GSettings *atspi_settings = NULL; - GVariant *variant = NULL; - char *value = NULL; - const char * const *schemas = NULL; - gboolean found = FALSE; - int i = 0; - - schemas = g_settings_list_schemas (); - - for (i = 0; schemas [i]; i++) - { - if (!strcmp (schemas[i], AT_SPI_SCHEMA)) - { - found = TRUE; - break; - } - } - - if (!found) - { - g_warning ("Accessibility: %s schema not found. Are you sure that at-spi or" - " at-spi2 is installed on your system?", AT_SPI_SCHEMA); - return NULL; - } - - atspi_settings = g_settings_new (AT_SPI_SCHEMA); - variant = g_settings_get_value (atspi_settings, ATK_BRIDGE_LOCATION_KEY); - value = g_variant_dup_bytestring (variant, NULL); - g_variant_unref (variant); - g_object_unref (atspi_settings); - - return value; -} - -static gboolean -a11y_invoke_module (const char *module_path) -{ - GModule *handle; - void (*invoke_fn) (void); - - if (!module_path) - { - g_warning ("Accessibility: invalid module path (NULL)"); - - return FALSE; - } - - if (!(handle = g_module_open (module_path, 0))) - { - g_warning ("Accessibility: failed to load module '%s': '%s'", - module_path, g_module_error ()); - - return FALSE; - } - - if (!g_module_symbol (handle, INIT_METHOD, (gpointer *)&invoke_fn)) - { - g_warning ("Accessibility: error library '%s' does not include " - "method '%s' required for accessibility support", - module_path, INIT_METHOD); - g_module_close (handle); - - return FALSE; - } - - invoke_fn (); - - return TRUE; -} - -/* - * It loads the atk-bridge if required. It checks: - * * If the proper gsetting key is set - * * If clutter has already enabled the accessibility - * - * You need to ensure that the atk-bridge was not loaded before this - * call, because in that case the application would be already - * registered on at-spi using the AtkUtil implementation on that - * moment (if any, although without anyone the application would - * crash). Anyway this is the reason of NO_AT_BRIDGE. - * - */ -void -shell_a11y_init (void) -{ - char *bridge_path = NULL; - - if (!should_enable_a11y ()) - return; - - if (clutter_get_accessibility_enabled () == FALSE) - { - g_warning ("Accessibility: clutter has no accessibility enabled" - " skipping the atk-bridge load"); - return; - } - - bridge_path = get_atk_bridge_path (); - - if (a11y_invoke_module (bridge_path) == FALSE) - { - g_warning ("Accessibility: error loading the atk-bridge. Although the" - " accessibility on the system is enabled and clutter" - " accessibility is also enabled, accessibility support on" - " GNOME Shell will not work"); - } - - /* NOTE: We avoid to load gail module, as gail-cally interaction is - * not fully supported right now. - */ - - g_free (bridge_path); -} diff --git a/src/shell-a11y.h b/src/shell-a11y.h deleted file mode 100644 index b285bd7e3..000000000 --- a/src/shell-a11y.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ -/* - * Copyright (C) 2010 Igalia, S.L. - * - * Author: Alejandro Piñeiro Iglesias - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef __SHELL_A11Y_H_ -#define __SHELL_A11Y_H_ - -G_BEGIN_DECLS - -void shell_a11y_init (void); - -G_END_DECLS - -#endif /* __SHELL_A11Y_H_ */